home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / wedl20.zip / WEDL.H < prev    next >
Text File  |  1992-07-22  |  19KB  |  375 lines

  1.  
  2. /*---------------------------------------------------------------------------*/
  3. /*                                                                           */
  4. /*          WEDL(tm) - Windows Enhanced Dialog Library                       */
  5. /*          Copyright (c) 1991-1992, Nemisoft, Inc.                          */
  6. /*          All Rights Reserved                                              */
  7. /*          Module:  WEDL.H                                                  */
  8. /*                                                                           */
  9. /*---------------------------------------------------------------------------*/
  10.  
  11. #if !defined( __WEDL_H )
  12.     #define __WEDL_H
  13.  
  14. /*---------------------------------------------------------------------------*/
  15.  
  16. /* Windows 3.0 SDK compatibility */
  17.  
  18. #if !defined( WINAPI )
  19.     #define CALLBACK FAR PASCAL
  20.     #define WINAPI FAR PASCAL
  21.     typedef unsigned int UINT;
  22.     typedef UINT WPARAM;
  23.     typedef LONG LPARAM;
  24.     typedef LONG LRESULT;
  25.     typedef HANDLE HINSTANCE;
  26.     typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
  27. #endif
  28.  
  29. /*---------------------------------------------------------------------------*/
  30.  
  31. /* form feature definitions */
  32.  
  33. #define FMF_NONE        0L      /* no features specified                  */
  34. #define FMF_OVERTYPE    1L      /* set Insert mode off by default         */
  35. #define FMF_UPDATE      2L      /* set all controls in update mode        */
  36. #define FMF_VKEYPRES    4L      /* perform validation after each keypress */
  37. #define FMF_VLEAVFLD    8L      /* do validation when user leaves field   */
  38. #define FMF_NOSELECT    16L     /* no auto-select of fields upon focus    */
  39. #define FMF_COMPAT      32L     /* compatibility mode                     */
  40.  
  41. /*---------------------------------------------------------------------------*/
  42.  
  43. /* field feature definitions */
  44.  
  45. #define FDF_NONE        0L      /* no features specified                  */
  46. #define FDF_COMPLETE    1L      /* field must be complete                 */
  47. #define FDF_NOTBLANK    2L      /* field cannot be blank                  */
  48. #define FDF_NOTZERO     4L      /* field cannot be zero                   */
  49. #define FDF_NOTEDIT     8L      /* field cannot be edited                 */
  50. #define FDF_MUSTEDIT    16L     /* field must be edited                   */
  51. #define FDF_UPDATE      32L     /* update existing data                   */
  52. #define FDF_NOSELECT    64L     /* no auto-select of field upon focus     */
  53. #define FDF_SPCFILL     128L    /* space-fill field from right            */
  54. #define FDF_ZEROFILL    256L    /* zero-fill numeric field from left      */
  55. #define FDF_BLNKZERO    512L    /* blank numeric field if equal to zero   */
  56. #define FDF_BLNKNEZ     1024L   /* blank not equal zero (numeric field)   */
  57. #define FDF_PHYSICAL    2048L   /* read/write data in physical format     */
  58. #define FDF_UPPER       4096L   /* convert characters to UPPERCASE        */
  59. #define FDF_LOWER       8192L   /* convert characters to lowercase        */
  60. #define FDF_PROPER      16384L  /* convert characters to Proper Case      */
  61. #define FDF_NUMERIC     32768L  /* standard numeric field                 */
  62. #define FDF_CALCNUM     65536L  /* calculator-style numeric field         */
  63. #define FDF_VKEYPRES    131072L /* perform validation after each keypress */
  64. #define FDF_VLEAVFLD    262144L /* do validation when user leaves field   */
  65. #define FDF_COMBO       524288L /* field belongs to a combo box           */
  66.  
  67. /*---------------------------------------------------------------------------*/
  68.  
  69. /* enable-link condition definitions */
  70.  
  71. #define ELC_BLANK       1L      /* field is blank                    */
  72. #define ELC_ZERO        2L      /* field contains a zero value       */
  73. #define ELC_EDITED      3L      /* field has been edited by the user */
  74. #define ELC_CHECKED     4L      /* button is checked                 */
  75.  
  76. /*---------------------------------------------------------------------------*/
  77.  
  78. /* field data type definitions */
  79.  
  80. #define FDT_NULL        0       /* 'pdata' pointer == NULL      */
  81. #define FDT_STRING      1       /* character string             */
  82. #define FDT_SHORT       2       /* 16-bit signed integer        */
  83. #define FDT_USHORT      3       /* 16-bit unsigned integer      */
  84. #define FDT_INTEGER     4       /* signed integer               */
  85. #define FDT_UNSIGNED    5       /* unsigned integer             */
  86. #define FDT_LONG        6       /* 32-bit signed long integer   */
  87. #define FDT_ULONG       7       /* 32-bit unsigned long integer */
  88. #define FDT_FLOAT       8       /* single precision real number */
  89. #define FDT_DOUBLE      9       /* double precision real number */
  90.  
  91. /*---------------------------------------------------------------------------*/
  92.  
  93. /* button feature definitions */
  94.  
  95. #define BTF_NONE        0L      /* no features specified                    */
  96. #define BTF_CHECKED     1L      /* button is initially checked              */
  97. #define BTF_GRAYED      2L      /* button is initially grayed               */
  98. #define BTF_UPDATE      4L      /* button is initialize according to pdata  */
  99. #define BTF_GENERIC     8L      /* button record holds generic control info */
  100. #define BTF_IDOK        16L     /* button is the "OK" button                */
  101. #define BTF_IDCANCEL    32L     /* button is the "Cancel" button            */
  102.  
  103. /*---------------------------------------------------------------------------*/
  104.  
  105. /* key status message definitions */
  106.  
  107. #define KSM_INSERT      0       /* Insert key status message    */
  108. #define KSM_CAPSLOCK    1       /* CapsLock key status message  */
  109. #define KSM_NUMLOCK     2       /* NumLock key status message   */
  110.  
  111. /*---------------------------------------------------------------------------*/
  112.  
  113. /* internal field error values (don't use these for your own error values) */
  114.  
  115. #define ERV_BLANK       27701   /* field is blank                       */
  116. #define ERV_INCOMPL     27702   /* field is incomplete                  */
  117. #define ERV_INVCHAR     27703   /* field contains invalid character(s)  */
  118. #define ERV_NOTEDIT     27704   /* user tried to edit noneditable field */
  119. #define ERV_UNEDITED    27705   /* field hasn't been edited             */
  120. #define ERV_ZERO        27706   /* field has a value of zero            */
  121.  
  122. /*---------------------------------------------------------------------------*/
  123.  
  124. /* error event definitions */
  125.  
  126. #define ERE_KEYPRESS    1       /* a key was pressed                 */
  127. #define ERE_LEAVEFLD    2       /* user attempted to leave the field */
  128. #define ERE_SELECTOK    3       /* user attempted to select "OK"     */
  129.  
  130. /*---------------------------------------------------------------------------*/
  131.  
  132. /* definitions of WEDL handles */
  133.  
  134. typedef HANDLE  HFORM;          /* handle of a form record   */
  135. typedef HANDLE  HFIELD;         /* handle of a field record  */
  136. typedef HANDLE  HBUTTON;        /* handle of a button record */
  137.  
  138. /*---------------------------------------------------------------------------*/
  139.  
  140. /* function pointer definitions for error handling and validation functions */
  141.  
  142. #if defined( STRICT )
  143.     typedef BOOL (CALLBACK *PERRFUNC) (HFORM,HFIELD,int,int,int);
  144.     typedef int (CALLBACK *PVALFUNC) (HFORM,HFIELD,LPSTR);
  145. #else
  146.     typedef FARPROC PERRFUNC;
  147.     typedef FARPROC PVALFUNC;
  148. #endif
  149.  
  150. /*---------------------------------------------------------------------------*/
  151.  
  152. /* definition of a field record */
  153.  
  154. typedef struct {
  155.     DWORD features;             /* field features                            */
  156.     DWORD help_context;         /* help context ID of help topic for field   */
  157.     LPSTR picture_string;       /* pointer to the field picture string       */
  158.     LPVOID pdata;               /* pointer to data type to write/update      */
  159.     PVALFUNC pvalid_func;       /* proc-instance address of validation func. */
  160.     HWND hcombo;                /* handle of combo box field belongs to      */
  161.     HWND hwnd;                  /* field's window handle                     */
  162.     HFIELD hfield;              /* field's memory handle                     */
  163.     HFIELD hnext_field;         /* handle of next field in linked list       */
  164.     int ctrl_id;                /* dialog control ID of edit control         */
  165.     int data_type;              /* data type pointed to by 'data' parameter  */
  166.     int decimal_position;       /* virtual logical position of decimal point */
  167.     int error_value;            /* unique error value                        */
  168.     int logical_size;           /* logical size of field                     */
  169.     int physical_size;          /* physical size of field                    */
  170.     BOOL has_changed;           /* flag - "field has changed"                */
  171. } FIELD;
  172.  
  173. typedef FIELD *     PFIELD;
  174. typedef FIELD FAR * LPFIELD;
  175.  
  176. /*---------------------------------------------------------------------------*/
  177.  
  178. /* field position information */
  179.  
  180. typedef struct {
  181.     LPSTR ppicture_str_pos;     /* pointer to picture string position      */
  182.     long selection;             /* selection                               */
  183.     int logical_position;       /* logical position                        */
  184.     int physical_position;      /* physical position                       */
  185.     int val_char_occ;           /* validation character occurrence         */
  186.     BOOL to_right_of_dec;       /* position is to the right of the decimal */
  187.     char validation_char;       /* validation character for position       */
  188. } FIELD_POS;
  189.  
  190. typedef FIELD_POS *     PFIELD_POS;
  191. typedef FIELD_POS FAR * LPFIELD_POS;
  192.  
  193. /*---------------------------------------------------------------------------*/
  194.  
  195. /* definition of a form record */
  196.  
  197. typedef struct {
  198.     DWORD features;             /* form features                            */
  199.     PERRFUNC perror_func;       /* proc-instance address of error handler   */
  200.     FARPROC pdialog_proc;       /* address of dialog box's window procedure */
  201.     DWORD help_context;         /* default Windows Help context             */
  202.     LPSTR capslock_offmsg;      /* pointer to CapsLock "off" status message */
  203.     LPSTR capslock_onmsg;       /* pointer to CapsLock "on" status message  */
  204.     LPSTR help_file_name;       /* help file name                           */
  205.     LPSTR insert_offmsg;        /* pointer to Insert "off" status message   */
  206.     LPSTR insert_onmsg;         /* pointer to Insert "on" status message    */
  207.     LPSTR numlock_offmsg;       /* pointer to NumLock "off" status message  */
  208.     LPSTR numlock_onmsg;        /* pointer to NumLock "on" status message   */
  209.     long undo_selection;        /* undo selection                           */
  210.     HANDLE hhead_elink;         /* handle of head enable-link record        */
  211.     HANDLE hproc_array;         /* handle of window procedure array         */
  212.     HANDLE hundo_buffer1;       /* handle of field undo buffer #1           */
  213.     HANDLE hundo_buffer2;       /* handle of field undo buffer #2           */
  214.     HWND hdlg;                  /* form's dialog box window handle          */
  215.     HFORM hform;                /* form's memory handle                     */
  216.     HFORM hnext_form;           /* handle of next form in linked list       */
  217.     HFIELD hcurr_field;         /* handle of current node in field list     */
  218.     HFIELD herror_field;        /* handle of field in error                 */
  219.     HFIELD hhead_field;         /* handle of head node in field list        */
  220.     HBUTTON hhead_button;       /* handle of head node in button list       */
  221.     int cancel_id;              /* control ID of "Cancel" button            */
  222.     int capslock_id;            /* control ID of CapsLock status message    */
  223.     int error_event;            /* event which caused the error             */
  224.     int error_position;         /* logical position of the error            */
  225.     int error_value;            /* error value of field in error            */
  226.     int insert_id;              /* control ID of Insert status message      */
  227.     int numlock_id;             /* control ID of NumLock status message     */
  228.     int num_controls;           /* number of defined controls in form       */
  229.     int ok_id;                  /* control ID of "OK" button                */
  230.     int undo_level;             /* undo level                               */
  231.     BOOL edit_key_pressed;      /* flag - "an editing key was pressed"      */
  232.     BOOL help_invoked;          /* flag - "Windows Help has been invoked"   */
  233.     BOOL insert_mode;           /* flag - "insert mode on"                  */
  234.     BOOL in_error_handler;      /* flag - "in field error handler"          */
  235.     BOOL just_passed_dec;       /* flag - "just passed decimal point"       */
  236.     BOOL pressed_cancel;        /* flag - "Cancel was pressed"              */
  237. } FORM;
  238.  
  239. typedef FORM *     PFORM;
  240. typedef FORM FAR * LPFORM;
  241.  
  242. /*---------------------------------------------------------------------------*/
  243.  
  244. /* definition of a button record */
  245.  
  246. typedef struct {
  247.     DWORD features;             /* button features                          */
  248.     DWORD help_context;         /* help context ID of help topic for button */
  249.     LPINT pdata;                /* pointer to data to initialize/update     */
  250.     HWND hwnd;                  /* button's window handle                   */
  251.     HBUTTON hbutton;            /* handle of button's window                */
  252.     HBUTTON hnext_button;       /* handle of next button in linked list     */
  253.     int ctrl_id;                /* dialog control ID of button              */
  254.     int group_id;               /* group affiliation ID                     */
  255.     int off_value;              /* value stored at 'pdata' if not checked   */
  256.     int on_value;               /* value stored at 'pdata' if checked       */
  257.     BOOL has_changed;           /* flag - "button has changed"              */
  258. } BUTTON;
  259.  
  260. typedef BUTTON *     PBUTTON;
  261. typedef BUTTON FAR * LPBUTTON;
  262.  
  263. /*---------------------------------------------------------------------------*/
  264.  
  265. #if defined(__cplusplus)
  266.     extern "C" {
  267. #endif
  268.  
  269. /* button functions */
  270.  
  271. HBUTTON  WINAPI button_define( HFORM hform, int ctrl_id, LPINT pdata,
  272.                                int group_id, int on_value, int off_value,
  273.                                DWORD features, DWORD help_context );
  274. int      WINAPI button_get_check( HBUTTON hbutton );
  275. HBUTTON  WINAPI button_get_from_ctrl_id( HFORM hform, int ctrl_id );
  276. HBUTTON  WINAPI button_get_from_group( HFORM hform, int group_id );
  277. HBUTTON  WINAPI button_get_from_hwnd( HFORM hform, HWND hWnd );
  278. HWND     WINAPI button_get_hwnd( HBUTTON hbutton );
  279. BOOL     WINAPI button_has_changed( HBUTTON hbutton );
  280. LPBUTTON WINAPI button_lock( HBUTTON hbutton );
  281. int      WINAPI button_set_check( HBUTTON hbutton, int state );
  282. void     WINAPI button_unlock( HBUTTON hbutton );
  283.  
  284. /*---------------------------------------------------------------------------*/
  285.  
  286. /* character manipulation functions */
  287.  
  288. BOOL WINAPI char_is_printable( int ch );
  289. int  WINAPI char_to_lower( int ch );
  290. int  WINAPI char_to_upper( int ch );
  291.  
  292. /*---------------------------------------------------------------------------*/
  293.  
  294. /* field functions */
  295.  
  296. int     WINAPI field_data_to_log( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  297.                                   int data_type );
  298. HFIELD  WINAPI field_define( HFORM hform, int ctrl_id, LPVOID pdata,
  299.                              int data_type, LPSTR picture_string,
  300.                              DWORD features, PVALFUNC pvalid_func,
  301.                              int error_value, DWORD help_context );
  302. int     WINAPI field_get_character( HFIELD hfield, int position,
  303.                                     BOOL physical );
  304. int     WINAPI field_get_ctrl_id( HFIELD hfield );
  305. HFIELD  WINAPI field_get_from_ctrl_id( HFORM hform, int ctrl_id );
  306. HFIELD  WINAPI field_get_from_hwnd( HFORM hform, HWND hWnd );
  307. HWND    WINAPI field_get_hwnd( HFIELD hfield );
  308. int     WINAPI field_get_pos_info( HFIELD hfield, int logical_position,
  309.                                    LPFIELD_POS pfpos );
  310. int     WINAPI field_get_position( HFIELD hfield, LPFIELD_POS pfpos );
  311. int     WINAPI field_get_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  312. BOOL    WINAPI field_has_changed( HFIELD hfield );
  313. LPFIELD WINAPI field_lock( HFIELD hfield );
  314. int     WINAPI field_log_to_data( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  315.                                   int data_type );
  316. int     WINAPI field_log_to_phys( HFIELD hfield, LPSTR pbuf );
  317. int     WINAPI field_phys_to_log( HFIELD hfield, LPSTR pbuf );
  318. int     WINAPI field_set_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  319. void    WINAPI field_unlock( HFIELD hfield );
  320.  
  321. /*---------------------------------------------------------------------------*/
  322.  
  323. /* form functions */
  324.  
  325. HFORM  WINAPI form_begin( HWND hDlg, DWORD features, PERRFUNC perror_func );
  326. int    WINAPI form_cancel( HFORM hform );
  327. int    WINAPI form_end( HFORM hform );
  328. BOOL   WINAPI form_exists( HFORM hform );
  329. HFORM  WINAPI form_get_from_hdlg( HWND hDlg );
  330. HWND   WINAPI form_get_hdlg( HFORM hform );
  331. BOOL   WINAPI form_has_changed( HFORM hform );
  332. BOOL   WINAPI form_in_error_cond( HFORM hform );
  333. BOOL   WINAPI form_is_cancelled( HFORM hform );
  334. int    WINAPI form_load( HFORM hform );
  335. LPFORM WINAPI form_lock( HFORM hform );
  336. int    WINAPI form_ok( HFORM hform );
  337. int    WINAPI form_save( HFORM hform );
  338. int    WINAPI form_set_enable_link( HFORM hform, HANDLE hcontrol,
  339.                                     DWORD condition, int ctrl_id,
  340.                                     BOOL enable );
  341. int    WINAPI form_set_help( HFORM hform, LPSTR help_file_name,
  342.                              DWORD help_context );
  343. void   WINAPI form_unlock( HFORM hform );
  344. HFIELD WINAPI form_validate( HFORM hform );
  345.  
  346. /*---------------------------------------------------------------------------*/
  347.  
  348. /* generic control functions */
  349.  
  350. HANDLE WINAPI generic_define( HFORM hform, int ctrl_id, DWORD help_context );
  351.  
  352. /*---------------------------------------------------------------------------*/
  353.  
  354. /* key status message functions */
  355.  
  356. int WINAPI keystat_define( HFORM hform, int ctrl_id, int which,
  357.                            LPSTR onmsg, LPSTR offmsg );
  358.  
  359. /*---------------------------------------------------------------------------*/
  360.  
  361. /* string manipulation functions */
  362.  
  363. int  WINAPI str_delete_char( LPSTR pstr, int ch );
  364. void WINAPI str_insert_char( LPSTR pstr, int ch, int offs );
  365. BOOL WINAPI str_is_blank( LPSTR pstr );
  366. BOOL WINAPI str_is_value_zero( LPSTR pstr );
  367. void WINAPI str_trim_spaces( LPSTR pstr );
  368.  
  369. #if defined(__cplusplus)
  370.     }
  371. #endif
  372.  
  373. #endif  /* __WEDL_H */
  374.  
  375.